Skip to content

fix(fieldset): preserve VectorField.interp_method when extending FieldSet - #3065

Closed
boomesh11 wants to merge 1 commit into
Parcels-code:mainfrom
boomesh11:fix/preserve-vectorfield-interp-method
Closed

boomesh11 wants to merge 1 commit into
Parcels-code:mainfrom
boomesh11:fix/preserve-vectorfield-interp-method

Conversation

@boomesh11

Copy link
Copy Markdown

Fixes #3064.

Root Cause

Unlike Field.interp_method.setter, which persists the interpolator in self.model.field_to_interpolator[self.name], VectorField.interp_method.setter (src/parcels/_core/field.py) only updated self._interp_method on the VectorField instance. When FieldSet.add ( ieldset += other) called combined.reconstruct_fields(), StructuredModelData.construct_fields() and UnstructuredModelData.construct_fields() (src/parcels/_core/model.py) recreated each VectorField with the default interpolator, discarding custom VectorField.interp_method assignments.

Changes

  • src/parcels/_core/field.py: Persist VectorField.interp_method in self.U.model.field_to_interpolator[self.name] when set.
  • src/parcels/_core/model.py: Read any saved vector-field interpolator from self.field_to_interpolator in StructuredModelData.construct_fields() and UnstructuredModelData.construct_fields() before falling back to the default velocity interpolator.
  • ests/test_fieldset.py: Added est_fieldset_add_preserves_vector_field_interp_method.

Testing

  • pytest tests/test_fieldset.py -k "fieldset_add" -v (21 passed)

@fluidnumericsJoe

Copy link
Copy Markdown
Contributor

Hey @boomesh11 - could you please fill out the AI disclosure in the PR desciription, per the PR template ?

Is there a corresponding issue that this PR addresses ? If not, I'm curious to know what scenario you've encountered for which the proposed changes resolves a problem.

@fluidnumericsJoe

Copy link
Copy Markdown
Contributor

Duplicates #3064. Closing in favor of #3064

@github-project-automation github-project-automation Bot moved this from Backlog to Done in Parcels development Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Changes to VectorField.interp_method overridden when FieldSet extended

2 participants